<?
include('./inst.conf.php');
header("Content-type: text/javascript");
?>
/*------------------------------------------------*/
/*----------------[Loader Overlay]----------------*/
/*------------------------------------------------*/
function ChangeDasPanel(controllerPath, postParams, f) {
 
      if (typeof f == "function") f();

};


function showLoader(loader_title,details, f){
	if(loader_title == null){loader_title = "Laden..";}
	$('#page-loader-detail').hide();
	$('#page-loader-title').html(loader_title);
	$('#page-loader').fadeIn('50');
	$('#page-loader-detail-text').html(details + '<br>');
	$('#page-loader-background').fadeIn('50',function() {
		if (typeof f == "function") f();
	});
}

function hideLoader(){
	$('#page-loader').fadeOut('200');
	$('#page-loader-background').fadeOut('200');
}
function addLoadDetails(details){
	$('#page-loader-detail-text').append(details);
}


/*------------------------------------------------*/
/*-----------------[IDLE message]-----------------*/
/*------------------------------------------------*/

function showIDLE_Message(loader_title, user_name){
	if(loader_title == null){loader_title = "U was langer dan <?=$cfg['general']['idle']['min'];?> min inactief.";}
	$('#idle-username').html('Aangemeld als: <a>'+user_name+'</a>');
	$('#idle-title').html(loader_title);
	$('#idle-password').val('');
	$('#idle-password').hide();
	$('#idle-password-info').show();
	$('#idle-display').fadeIn('500');
	$('#idle-background').fadeIn('500');
}

function IDLE_CheckPWD(){
	if($('#idle-password').val() != ''){
		$.post('./src/login.json.php?UserIsInActive=false', { p: $('#idle-password').val() },
		            function(j){
		                if(j[0].status == "succes"){
		                	IDLE_Active = false;
		                	hideIDLE_Message();
		                }else{
		                	var conf = {
		                		frequency: 10000,
		                		spread: 2,
		                		duration: 500
		                	};		
		                	$("#idle-display").vibrate(conf);
		                	$.notify({text: j[0].errorText, title: j[0].errorTitle, icon:'images/dialog-error.png'});
		                	$('#idle-password').val('')
		                					   .hide();
		                	$('#idle-password-info').css('color','#CCC')
		                							.show();
		                	
		                }
		            }, 'json');
	}else{
		$.notify({text: 'U heeft geen wachtwoord ingevoerd', title:'Fout', icon:'images/dialog-error.png'});
		$('#idle-password-info').css('color','red');
	}
}
function hideIDLE_Message(){
	$('#idle-display').fadeOut('100');
	$('#idle-background').fadeOut('100');
}

/*------------------------------------------------*/
/*----------------[UPDATE message]----------------*/
/*------------------------------------------------*/

function UPDATE_Message_show(){
	$('#UPDATE-display').fadeIn('500');
	$('#UPDATE-background').fadeIn('500');
}
function UPDATE_Message_hide(){
	$('#UPDATE-display').fadeOut('500');
	$('#UPDATE-background').fadeOut('500');
}

/*------------------------------------------------*/
/*---------------[Wachtwoord vergeten]------------*/
/*------------------------------------------------*/

function showwwVergeten_Message(){
	$('#wwVergeten-display').fadeIn('500');
	$('#wwVergeten-background').fadeIn('500');
}

function hidewwVergeten_Message(){
	$('#wwVergeten-display').fadeOut('slow', function(){
		$('#wwVergeten-content').show().html('U bent uw wachtwoord vergeten. Om een nieuw wachtwoord aan te vragen dient u uw gebruikersnaam en email in te voeren. U krijgt dan per mail uw nieuwe wachtwoord toegestuurd.');
		$('#wwVergeten-Gebruikersnaam').val('Gebruikersnaam').css('color', '#ccc').show();
		$('#wwVergeten-Email').val('Email').css('color', '#ccc').show();
		$('#wwVergeten-buttons').html('<a href="javascript:void(\'0\');" onclick="hidewwVergeten_Message();" class="negative"><img src="./images/icon-cross.png" alt=""/>Annuleren</a><a href="javascript:void(\'0\');" class="positive" name="save" id="save_butt" onclick=" wwVergete_Check();"><img src="./images/icon-apply.png" alt=""/>Stuur</a>');
	});
	$('#wwVergeten-background').fadeOut('slow');
	
}

function wwVergete_Check(){
	if($('#wwVergeten-Gebruikersnaam').val() != 'Gebruikersnaam' && $('#wwVergeten-Email').val() != 'Email'){
		$.post('./src/login.json.php?LostPassword=true', { e: $('#wwVergeten-Email').val(), g: $('#wwVergeten-Gebruikersnaam').val() },
		            function(j){
		                if(j[0].status == "succes"){
		                	$('#wwVergeten-content').hide()
		                							.html('Het nieuwe wachtwoord is naar uw email adres verzonden! als u de mail niet in uw inbox ziet controleer dan uw <B>SPAM</b> folder.')
		                							.fadeIn('slow');
		                	$('#wwVergeten-Gebruikersnaam').fadeOut('slow');
		                	$('#wwVergeten-Email').fadeOut('slow');
		                	$('#wwVergeten-buttons').hide()
		                							.html('<a href="javascript:void(\'0\');" onclick="hidewwVergeten_Message();" class="negative"><img src="./images/icon-cross.png" alt=""/>Sluiten</a>')
		                							.fadeIn('slow');
		                	
		                }else if(j[0].status == "alaangevraagt"){
		                	$('#wwVergeten-content').hide()
		                							.html(j[0].Text)
		                							.fadeIn('slow');
		                	$('#wwVergeten-Gebruikersnaam').fadeOut('slow');
		                	$('#wwVergeten-Email').fadeOut('slow');
		                	$('#wwVergeten-buttons').hide()
		                							.html('<a href="javascript:void(\'0\');" onclick="hidewwVergeten_Message();" class="negative"><img src="./images/icon-cross.png" alt=""/>Sluiten</a>')
		                							.fadeIn('slow');
		                	
		                }else{
		                	var conf = {
		                		frequency: 10000,
		                		spread: 2,
		                		duration: 500
		                	};		
		                	$("#wwVergeten-display").vibrate(conf);
		                	$.notify({text: j[0].errorText, title: j[0].errorTitle, icon:'images/dialog-error.png'});
		                }
		            }, 'json');
	}else{
		$.notify({text: 'U heeft geen gebruikersnaam en of emailadres ingevoerd', title:'Fout', icon:'images/dialog-error.png'});
	}
}





